import json

from config.prompts_version1 import prompt_talk_to_boss, prompt_talk_to_colleague
from config.prompts_version2 import prompt_project_describe_version2
from network.BaiduConnector import BaiduConnector


async def send_prompt_project_describe(relationship, my_name, task, project_name, boss_name):
    message_content = prompt_project_describe_version2.format(relationship, my_name, task, project_name, boss_name,
                                                      boss_name, boss_name, my_name)

    message = [{
        "role": "user",
        "content": message_content
    }]

    response = await BaiduConnector().send(message, 0.5, 1, system='')
    data = json.loads(response.data)
    print(f'send message {message_content}')
    print(f"boss name: {boss_name}")
    print(f"my name: {my_name}")
    print(data['result'])
    print("-"*40)
    return data['result']


async def send_prompt_talk_to_boss(relationship, me_describe, boss_describe, tasks_me, tasks, project_describe, talks, boss_name, my_name):
    message_content = prompt_talk_to_boss.format(relationship,
                                         str(me_describe),
                                         str(boss_describe),
                                         str(tasks_me),
                                         str(tasks),
                                         str(project_describe),
                                         talks
                                         )
    message = [{
        "role": "user",
        "content": message_content
    }]

    response = await BaiduConnector().send(message, 0.5, 1, system=f'你是{boss_name},使用你的语气回复我')
    data = json.loads(response.data)
    print(f'send message {message_content}')
    print(data)
    print(data['result'])
    print("-"*40)
    return data['result']


async def send_prompt_talk_to_employee(relationship, colleague_describe, tasks_me, tasks_colleague, talks, colleague_name, my_name):
    # todo 可能可以改为多轮对话的情况
    message_content = prompt_talk_to_colleague.format(relationship,
                                         str(colleague_describe),
                                         str(tasks_colleague),
                                         str(tasks_me),
                                         talks
                                         )

    message = [{
        "role": "user",
        "content": message_content
    }]

    response = await BaiduConnector().send(message, 0.5, 1, system=f'你是{colleague_name},使用你的语气回复我')
    data = json.loads(response.data)
    print(f'send message {message_content}')
    print(data['result'])
    print("-"*40)
    return data['result']
